avalon.filters.getStatus=function(val) {
	var result='';
	if(val=='0') {
		result=$.i18n.prop("fail");
	}else if(val=='1') {
		result=$.i18n.prop('success');
	}
	return result;
}

var recordPage = avalon.define({
	$id: "recordPage",
	noData:"",
	records: [],
	getStatus:function(){
		console.log(this);
		return '';
	}
});

mui.ready(function() {
	var uid = $("#uid").val();
	if("" == uid) {
		mui.openWindow({
			url: "dahua://login"
		});
		return false;
	}
	var pageNo = 1;
	var mui_record = mui('#record-list');
	mui.init({
		pullRefresh: {
			container: "#record-list",
			up: {
				auto: true,
				contentdown: $.i18n.prop('Pull_down_to_refresh'),
				contentrefresh: $.i18n.prop('Loading'),	
				contentover: $.i18n.prop('Release_to_immediate_refresh'),
				contentnomore: $.i18n.prop('noData'),
				callback: function() {
					recordPage.noData="";
					setTimeout(function() {
						mui.ajax('/record/list.json', {
							data: {
								'uid': uid,
								'pageNo': pageNo
							},
							dataType: 'json',
							success: function(items) {
								var records = recordPage.records;
								avalon.each(items, function(i, item) {
									records.push(item);
								});
								recordPage.records = records;
								mui_record.pullRefresh().endPullupToRefresh(false);
								if(recordPage.records.length==0){
									recordPage.noData="<img src='../../resources/images/noDataImg.png'><p>"+$.i18n.prop('No_data')+"</p>";
								}
								i18nReady();
							}
						});
						pageNo = pageNo + 1;
					}, window.DAHUA_CONFIG.LOADING_TIME);

				}
			}
		}
	});

});